//
//  满意度调查 @2017-6-5
//
//

#import "HSatisViewController.h"
#import "InitDbTable.h"
#import "Model_Hr_SatType.h"
#import "HSatisDetailViewController.h"
#import "HNurseAssessRecordViewController.h"
@interface HSatisViewController ()

@property (nonatomic ,strong) NSMutableArray *dataArray;
@property (nonatomic ,strong) NSMutableArray *resultArray;
@property (nonatomic ,strong) NSDictionary *paramDic;
@end

@implementation HSatisViewController

-(instancetype)initWithParam:(NSDictionary *)param{
    
    self = [super init];
    if(self){
        self.dataArray = [NSMutableArray new];
        self.resultArray = [NSMutableArray new];
        self.paramDic = param;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.myTableView];
    [self getTypeData];
    
    UIBarButtonItem *UploadButton = [[UIBarButtonItem alloc] initWithTitle:@"记录"
                                                                     style:UIBarButtonItemStylePlain
                                                                    target:self
                                                                    action:@selector(didUploadButttonClicked:)];
    
    self.navigationItem.rightBarButtonItem = UploadButton;

}
- (void)didUploadButttonClicked:(UIButton *)sender
{
    HNurseAssessRecordViewController *HNurseVC = [[HNurseAssessRecordViewController alloc]initWithMenuParam:nil];
    [self.navigationController pushViewController:HNurseVC animated:YES];
    HNurseVC.title = @"历史记录";
    HNurseVC.type = @"manyidu";
}

- (void)getTypeData
{
    InitDbTable *initDb = [[InitDbTable alloc]init];
    self.dataArray = [initDb GetHSatisfcation];
    
}
- (UITableView *)myTableView
{
    if (!_myTableView) {
        _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, NavBarHeight, ScreenWidth , ScreenHeight - NavBarHeight) style: UITableViewStylePlain];
        _myTableView.dataSource = self;
        _myTableView.delegate = self;
        _myTableView.tableFooterView = [[UIView alloc]init];
        [_myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    }
    return _myTableView;
}


#pragma mark  委托  UITableView


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"cell";
    UITableViewCell *cell = [self.myTableView dequeueReusableCellWithIdentifier:cellID];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
    
    Model_Hr_SatType *model = self.dataArray[indexPath.row];
    cell.textLabel.text = model.TYPE_NAME;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    Model_Hr_SatType *model = self.dataArray[indexPath.row];
    HSatisDetailViewController *HSatisVC = [[HSatisDetailViewController alloc]initWithTypeID:model.TYPE_ID param:self.paramDic] ;
    HSatisVC.title = model.TYPE_NAME;
    [self.navigationController pushViewController:HSatisVC animated:YES];
}


@end
